<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../../vue.js/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <div>{{name}}</div>
      <!-- <button-counter></button-counter> -->
      <!-- <button-counter></button-counter>
      <button-counter></button-counter> -->
      <xd></xd>
    </div>
    <script>
      // 全局注册
      // Vue.component('button-counter', {
      //   data() {
      //     return { count: 0 };
      //   },
      //   template: '<button v-on:click="count++">点击了 {{ count }} 次</button>',
      // });

      const aa = Vue.extend({
        data() {
          return {
            text: '小滴',
          };
        },
        template: '<p>{{text}}</p>',
      });

      // 局部注册
      const xd = Vue.extend({
        data() {
          return { count: 0 };
        },
        template: `<div>
          <button v-on:click="count++">点击了 {{ count }} 次</button>
          <aa></aa>
          </div>`,
        components: {
          aa,
        },
      });

      new Vue({
        el: '#app',
        data: {
          name: '小滴课堂',
        },
        components: {
          xd,
        },
      });
    </script>
  </body>
</html>
